<?php
namespace app\api\model;
use think\Model;

class Market extends Model
{
    protected $autoWriteTimestamp = true;
	protected $updateTime = false;
    protected $pk = 'id';

    // 关联客户（加盟商）
    public function falliance() {
        return $this->hasOne('\app\api\model\Alliance','id','alliance_id')->bind(
            ['name']);
    }




    // 获取分类
    public function finished() {
        return $this->hasMany('MarketList','market_id');
    }

	public static function getFinished() {
		$result = self::with([
			'finished' => function ($query) {
				$query->with(['fproduct'])
					->order(['id' => 'desc']);
			}
        ]);
        
		// ->where('alliance_id', $id)
		// ->select();

		return $result;
	}
}

